home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 3872 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.2 KB  |  44 lines

  1. Newsgroups: comp.lang.c
  2. Path: mxsld2.pd.infn.it!LORETI
  3. From: loreti@mxsld2.pd.infn.it (Maurizio Loreti)
  4. Subject: Re: Split Filename
  5. X-Nntp-Posting-Host: mxsld2.pd.infn.it
  6. Message-ID: <DM23s4.77J@news.cern.ch>
  7. Sender: news@news.cern.ch (USENET News System)
  8. Reply-To: loreti@mxsld2.pd.infn.it
  9. Organization: I.N.F.N. Padova - CDF/CMS VAXcluster
  10. References: <4e6lsr$8ar@news1.radix.net>,<31075FB4.3E53@cmt.lpr.mail.carel.fi>
  11. Date: Wed, 31 Jan 1996 17:40:50 GMT
  12.  
  13. In article <31075FB4.3E53@cmt.lpr.mail.carel.fi>, Ari Lukumies <aril@cmt.lpr.mail.carel.fi> writes:
  14. >Jim Ward wrote:
  15. >> 
  16. >> Is there a C function that will split
  17. >> /home/file.c into /home and file.c ?
  18. >> 
  19. >> Thanks,
  20. >> 
  21. >> Jim Ward
  22. >
  23. >You could try:
  24. >
  25. >    char    pathandfile[] = "/home/file.c";
  26. >    char    *path = pathandfile;
  27. >    char    *p = strrchr(pathandfile, '/');
  28. >    char    *filename = p + 1;
  29. >    *p = '\0';
  30. >
  31. >Also, some systems have functions named makepath and splitpath.
  32. >
  33. >Later,
  34. >AriL
  35. >
  36. >    
  37. >-- 
  38. >All my opinions are mine and mine alone.
  39.  
  40. Try with pathhandfile[] = "file.c" ...  core dump.
  41. --
  42. Maurizio Loreti                       http://mvxpd5.pd.infn.it/wwwcdf/mlo.html
  43. Un. of Padova, Dept. of Physics - Padova, Italy          loreti@padova.infn.it
  44.